/**
 * Project Name:sq580_ow;<br/>
 * File Name:CORSConfiguration;<br/>
 * Package Name:com.sq580.ow.config;<br/>
 * Date: 2018-06-29 14:01;<br/>
 * Copyright (c) 2018, www.sq580.com All Rights Reserved.;<br/>
 */
package com.sq580.ow.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author zh
 * @ClassName cn.saytime.config.CORSConfiguration
 * @Description
 */
@Configuration
public class CORSConfiguration {

    @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurerAdapter() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
//				registry.addMapping("/api/**");
                registry.addMapping("/**")
                        .allowedOrigins("http://domain.com", "http://domain2.com")
                        .allowedMethods("GET", "POST", "DELETE", "PUT", "OPTIONS")
                        .allowCredentials(false).maxAge(3600);
            }
        };
    }
}
